//
//  DAUMonitorWarningTVC.m
//  DAU-iOS
//
//  Created by XiangDongMBP on 2016/11/18.
//  Copyright © 2016年 East. All rights reserved.
//

#import "DAUMonitorWarningTVC.h"
#import "DAUMonWarnItemTCell.h"

@interface DAUMonitorWarningTVC ()

@property (nonatomic, readonly) NSArray<DAUColContactItem *> *contact;

@end

static NSString *const kReuseCellId = @"DAUMonWarnItemTCell";

@implementation DAUMonitorWarningTVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initNavigationBar];
    [self initSubViews];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    [self refreshWholeView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSArray<DAUColContactItem *> *)contact {
    return DAU_APP_DELEGATE.dauModel.engineDetail.result.contact;
}

- (void)initNavigationBar {
    self.navigationItem.title = @"机房";
}

- (void)initSubViews {
    UINib *cellNib = [UINib nibWithNibName:kReuseCellId bundle:nil];
    [self.tableView registerNib:cellNib forCellReuseIdentifier:kReuseCellId];
    
}

- (void)refreshWholeView {
    [self.tableView reloadData];
}

#pragma mark - <UITableViewDelegate>代理
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 70;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

#pragma mark - <UITableViewDataSource>代理
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.contact.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    DAUMonWarnItemTCell *cell = [tableView dequeueReusableCellWithIdentifier:kReuseCellId forIndexPath:indexPath];
    [cell configViewWithData:self.contact[indexPath.row]];
    return cell;
}

@end
